package com.controller;

import com.domain.JsonResult;
import com.domain.sys.SysMenu;
import com.service.SysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/menu")
public class MenuController {

    @Autowired
    private SysMenuService sysMenuService;

    @GetMapping("/doFindObjects")
    public JsonResult doFindObjects(){
        return new JsonResult(sysMenuService.findObject());
    }

    @RequestMapping("/doDeleteObject")
    public JsonResult doDeleteObject(Integer id){
        sysMenuService.deleteObject(id);
        return new JsonResult("delete ok");
    }

    @GetMapping("/doFindZtreeMenuNodes")
    public JsonResult doFindZtreeMenuNodes(){
        return new JsonResult(sysMenuService.findZtreeMenuNodes());
    }

    @RequestMapping("/doSaveObject")
    public JsonResult doSaveObject(SysMenu sysMenu){
        sysMenuService.insertObject(sysMenu);
        return  new JsonResult("save ok");
    }

    @RequestMapping("/doUpdateObject")
    public JsonResult doUpdateObject(SysMenu sysMenu){
        sysMenuService.updateObject(sysMenu);
        return new JsonResult("update ok");
    }

}
